<template>
	<view class="p20">
		<form-list ref="form" :list="list" boxClass=""></form-list>

		<view class="h120"></view>
		<view class="pf bottom0 left0  w-max flex z-index2">
			<view class="p24 flex1">
				<u-button type="warning" ripple @click="submit">修改信息</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: ''
			};
		},
		onLoad() {
			let user = this.$user
			this.list = [{
					name: '姓名',
					field: 'name',
					rightIcon: false
				}, {
					name: '身份证号',
					field: 'card_no',
					rightIcon: false
				}, {
					name: '手机号码',
					field: 'mobile',
					rightIcon: false
				},
				{
					name: '常驻所在地',
					field: 'city_id',
					value: user.city,
					value_id: user.city_id,
					click: (item) => {
						uni.$once('setAdd', e => {
							item.value = e.name
							item.value_id = e.id
						})
						this.$u.route('/pages/index/chooseAddress/chooseAddress')
					},
					disabled: true,
				},
				{
					type: 'textarea',
					name: '具体地址',
					field: 'address',
					rightIcon: false
				},
				{
					name: '常驻陪诊医院',
					field: 'hospitals_id',
					value: user.hospitals,
					value_id: user.hospitals_id?.toString()||'',
					click: (item) => {
						uni.$once('setDome', e => item.value_id = e)
						uni.$once('setDomeName', e => item.value = e)
						this.$u.route('/pages/my/serve/hospitalSel', {
							hospitals: item.value_id
						})
					},
					disabled: true,
				},
				{
					name: '护龄',
					field: 'service_year',
					rightIcon: false
				},
				{
					type: 'img',
					name: '身份证正面',
					field: 'card_pros',
					value: user.card_pros_img,
					value_id: user.card_pros,
					rightIcon: false,
					labelPosition: 'top',
					inputAlign: 'left',
				},
				{
					type: 'img',
					name: '身份证反面',
					field: 'card_cons',
					value: user.card_cons_img,
					value_id: user.card_cons,
					rightIcon: false,
					labelPosition: 'top',
					inputAlign: 'left',
				},
				{
					type: 'img',
					name: '资格证书',
					field: 'certificate',
					value_id: user.certificate,
					value: user.certificate_img,
					rightIcon: false,
					labelPosition: 'top',
					inputAlign: 'left',
					max: '9'
				},
				{
					type: 'img',
					name: '健康证明',
					field: 'report',
					value: user.report_img,
					value_id: user.report,
					rightIcon: false,
					labelPosition: 'top',
					inputAlign: 'left',
				},
			]

			this.list = this.list.map(item => {
				if (item.list) {} else if (item.value_id) {} else {
					item.value = this.$user[item.field] || item.value
				}
				return item
			})
		},
		methods: {
			submit() {
				let form = this.$refs.form.submit()
				this.$request('/master/my/editInfo', form).then(res => {
					this.$msg(res.msg)
					setTimeout(this.$navBack, 800)
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F8F8F8;
	}
</style>
